[PW_SID:1123580] Mixing bpf2bpf and tailcalls for RV64#2245
[PW_SID:1123580] Mixing bpf2bpf and tailcalls for RV64#2245linux-riscv-bot wants to merge 8 commits into
Conversation
Extract the is_struct_ops_tramp helper, and use it in riscv as the current checks are somewhat hacky. Signed-off-by: Pu Lehui <pulehui@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
When bpf_int_jit_compile() is called for subprograms, it returns early during the first pass (!prog->is_func || extra_pass is false), keeping ctx->offset alive for the subsequent extra pass. If JIT compilation fails for a later subprogram, the BPF core aborts and calls bpf_jit_free() to clean up the first subprogram. However, bpf_jit_free() fails to free jit_data->ctx.offset, which causes a memory leak of the JIT context offsets array. Fix this by adding the missing kfree(jit_data->ctx.offset) in bpf_jit_free(). Fixes: 48a8f78 ("bpf, riscv: use prog pack allocator in the BPF JIT") Reported-by: Sashiko <sashiko-bot@kernel.org> Signed-off-by: Pu Lehui <pulehui@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
It is unnecessary to allocate continuous physical memory for cache buffer, and when ebpf program is too large, it may cause memory allocation failure. Acked-by: Björn Töpel <bjorn@kernel.org> Signed-off-by: Pu Lehui <pulehui@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
When CONFIG_CFI_CLANG is enabled, prog->bpf_func already skips the kcfi instruction during setup. Including it again in the tailcall jump offset causes it to jump over an extra 4 bytes, skipping the stack pointer adjustment, which will result in kernel stack corruption. Fixes: 30a59cc ("riscv, bpf: Fix possible infinite tailcall when CONFIG_CFI_CLANG is enabled") Reported-by: Sashiko <sashiko-bot@kernel.org> Signed-off-by: Pu Lehui <pulehui@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add RV_TAILCALL_OFFSET macro to format tailcall offset, and correct the relevant comments. Signed-off-by: Pu Lehui <pulehui@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
In the current RV64 JIT, if we just don't initialize the TCC in subprog, the TCC can be propagated from the parent process to the subprocess, but the updated TCC of the parent process cannot be restored when the subprocess exits. Since the RV64 TCC is initialized before saving the callee saved registers into the stack, we cannot use the callee saved register to pass the TCC, otherwise the original value of the callee saved register will be destroyed. So we implemented mixing bpf2bpf and tailcalls similar to x86_64, i.e. using a non-callee saved register to transfer the TCC between functions, and saving that register to the stack to protect the TCC value. As for the tailcall hierarchy issue, inspired by the s390's low-overhead approach, we store TCC from RV_REG_TCC back to stack after calling bpf2bpf call or calling orig bpf func in bpf trampoline. Tests test_bpf.ko and test_verifier have passed, as well as the relative testcases of test_progs*. Signed-off-by: Pu Lehui <pulehui@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The RV64 BPF JIT now supports mixing bpf2bpf and tailcalls. Therefore, the tailcall_bpf2bpf tests can be safely removed from the riscv64 denylist. Signed-off-by: Pu Lehui <pulehui@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 1: "[bpf-next,v6,1/7] bpf: Extract the is_struct_ops_tramp helper" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 2: "[bpf-next,v6,2/7] riscv, bpf: Fix memory leak in bpf_jit_free" |
|
Patch 5: "[bpf-next,v6,5/7] riscv, bpf: Add RV_TAILCALL_OFFSET macro to format tailcall offset" |
|
Patch 5: "[bpf-next,v6,5/7] riscv, bpf: Add RV_TAILCALL_OFFSET macro to format tailcall offset" |
|
Patch 5: "[bpf-next,v6,5/7] riscv, bpf: Add RV_TAILCALL_OFFSET macro to format tailcall offset" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 6: "[bpf-next,v6,6/7] riscv, bpf: Mixing bpf2bpf and tailcalls" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
|
Patch 7: "[bpf-next,v6,7/7] selftests/bpf: Remove tailcalls tests from DENYLIST.riscv64" |
a50938c to
40ba5ca
Compare
PR for series 1123580 applied to workflow__riscv__fixes
Name: Mixing bpf2bpf and tailcalls for RV64
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1123580
Version: 6